home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / TIMING.SWG / 0028_Timing....pas < prev    next >
Pascal/Delphi Source File  |  1995-02-28  |  2KB  |  50 lines

  1. {
  2. SPEEDING UP YOUR SYSTEM TIMER ... It's surprisingly easy to speed up the
  3. system timer.  To speed up the system timer by a factor of 2, call
  4. "goosetimer(2)", which looks like this:
  5. }
  6.  
  7. procedure goosetimer(goose: byte);    { Speed up system timer }
  8. var gooseword: word;
  9. begin
  10.   gooseword := $ffff div goose;       { Number of oscillations between ticks }
  11.   port[$43] := $36;                   { Set timer at new speed }
  12.   port[$40] := lo(gooseword);
  13.   port[$40] := hi(gooseword);
  14.   end;
  15. {
  16. In that procedure, you are telling the timer chip how many chip oscillations
  17. to wait before generating a "tick".  The default is to generate a "tick"
  18. every 65536 cycles, or 18.2 times per second (which also works out to 65536
  19. "ticks" per hour).  The drawback here is that the system clock will speed up
  20. accordingly, as will all functions dependent on the reception of "ticks".
  21. So a useful approach is to reprogram Int $08 such that additional "ticks"
  22. are not passed along to the standard system functions.  The way to
  23. accomplish that is to generate an "End of Interrupt" command on all the
  24. additional "ticks" instead of invoking the "original" Int 08h ISR.  The
  25. "End of Interrupt" command is a command that, much like the STI instruction,
  26. enables subsequent hardware interrupts to be processed.  Code is in order:
  27. }
  28. procedure newtimint; interrupt;   { new timer interrupt }
  29. begin
  30.   if ticklooper > 0 then          { "suppress" this "tick" }
  31.     port[$20] := $20              { "End-of-Interrupt" command }
  32.    else begin
  33.     asm pushf; end;               { call old timer interrupt }
  34.     oldtimint;
  35.     end;
  36.   inc(cloktick);                  { update "tick" counter }
  37.   inc(ticklooper);
  38.   if ticklooper = goosefactor then ticklooper := 0;
  39.   end;
  40.  
  41. So start the ball rolling like so:
  42.  
  43.   goosetimer(goose);                  { speed up timer }
  44.   goosefactor := goose;               { record speed increase }
  45.   getintvec($08, @oldtimint);         { record location of old interrupt }
  46.   setintvec($08, @newtimint);         { install new interrupt procedure }
  47.   cloktick := 0;                      { set counter to 0 }
  48.   ticklooper := 0;                    { set "extra tick" determiner to 0 }
  49.  
  50.